package net.dopan.pigframe.auth.service;

import net.dopan.pigframe.api.fegin.UserServiceApi;
import net.dopan.pigframe.auth.util.UserDetailsImpl;
import net.dopan.pigframe.core.model.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * @Package: net.dopan.pigframe.auth.service
 * @Title: UserDetailServiceImpl
 * @Description: 用户详情
 * @author: 刘宽
 * @date: 2018/10/10 11:10
 */
@Service("userDetailService")
public class UserDetailServiceImpl implements UserDetailsService {

    @Autowired
    private UserServiceApi userServiceApi;

    @Override
    public UserDetailsImpl loadUserByUsername(String username) throws UsernameNotFoundException {
        UserVO userVo = userServiceApi.findUserByUsername(username);
        return new UserDetailsImpl(userVo);
    }
}
